package main

import "fmt"

func maxProfit(prices []int) int {
    if len(prices) <= 1 {
        return 0
    }
    var min, max int
    min = int(^uint(0) >> 1)
    for _, p := range prices {
        if p < min {
            min = p
        }
        if p - min > max {
            max = p - min
        }
    }
    return max
}

func main() {
    var prices []int = []int{7,1,5,3,6,4}
    res := maxProfit(prices)   
    fmt.Println(res)
}
